import axios from "axios";

//基础axios配置
const serve = axios.create({
	baseURL: "http://cgapi.1doc1.com.cn/",
	timeout: 98000,
	headers: {
		'content-type': 'application/json'
	}
})

//请求拦截器，对参数做全局处理，拼接请求头等
serve.interceptors.request.use(config=>{

    let token = localStorage.getItem("token")
    if(token){
        config.headers.token=token
    }
    return config;
})


//响应拦截器，全局处理返回的数据，及抛出错误处理
serve.interceptors.response.use(response=>{
    return response.data;
},error=>{
    console.log(error)
})

export default serve;

